home *** CD-ROM | disk | FTP | other *** search
- A Little Unofficial Information on TOY Prolog
-
- Several people have asked for some sort of documentation in english for TOY
- Prolog. While I have not yet been able to get the docs translated, here is
- a summary of what I have been able to determine so far (correct me if I'm
- wrong!):
-
- - TOY Prolog operates almost exactly like the system described in
- 'Programming in Prolog' by Clocksin & Mellish. If you don't have
- this book, GET IT. You will be able to operate TOY Prolog from
- the examples shown in the book.
-
- - You may not enter facts or rules directly from the keyboard (it always
- tries to evaluate them). There are two ways that I have used to do this:
-
- (1) Use consult(user). This will cause the interpreter to treat the
- terminal as if it were a disk file. You can enter anything you
- like this way. Terminate the input with 'end.'.
-
- (2) Use assert. If you press the <insert> key it will type 'assert('.
- You can then enter a fact or rule, terminated with ').' and the
- interpreter will accept it. For example,
-
- assert(likes(john,mary)).
-
- - To load a database that you have created with a text editor enter
-
- consult('filename').
-
- For example, to load a file called DATABASE which is in a folder called
- PROLOG on drive B enter
-
- consult('b:\prolog\database').
-
- The interpreter will read the file, typing it as it goes so that you
- can see what is going on.
-
- - After you have an application debugged you can 'pre-interpret' it so
- that it will be stored in tokenized form and will load much faster.
- To do this enter
-
- translate('oldfile','newfile').
-
- For example, to 'compile' the DATABASE file we used before enter
-
- translate('b:\prolog\database','b:\prolog\database.toy').
-
- To load a 'compiled' database use the 'sysload' predicate. For example,
-
- sysload('b:\prolog\database.toy').
-
- - Use 'shift''alt''help' to interrupt the interpreter and enter the
- debugger. The debugger allows the following commands:
-
- A - Abort
- B - Backtrace
- C - Continue
- D - Debug on/off (like 'debug' and 'nodebug')
- F - Fail
- S - Step
-
- - To exit the interpreter (back to the desktop) enter 'stop.'.
-
- - There are some differences between TOY prolog and the syntax described
- in C & M. Here are a few:
-
- (1) The 'name' predicate is called 'pname' and 'pnamei'. 'pnamei' treats
- the list as a list of integers. 'pname' treats the list as a list of
- symbols (characters?).
-
- (2) The 'findall' predicate is called 'bagof'. It seems to operate
- identically.
-
- (3) When a query succeeds you may ask for another solution by entering
- ';', however, to stop execution and return to the '?-' prompt you
- must enter '.', not just <CR> as in C & M.
-
- - The editor utility ('editor.toy') will allow you to edit a predicate
- that is made up of several clauses. It will not allow you to edit
- individual clauses. It is invoked by entering edit(predicate/arity).
- The following are the editor commands:
-
- e predicate/arity - invoke a new copy of the editor to edit another
- predicate.
- x - exit the current copy of the editor.
- + or <CR> - move to the next clause.
- - - move to the previous clause.
- t - move to clause 0.
- b - move to the last clause.
- l - list the entire predicate.
- d - delete the current clause.
- i - insert clauses ('end.' terminates input).
- f filename - insert clauses from a file.
- p - invoke a new copy of the interpreter to test
- the predicate.
-
- - The calltree utility ('calltree.toy') will display a tree diagram of
- the predicates (and their arity) that are invoked when the target
- predicate is invoked. To use it enter 'calltree(predicate/arity)'.
-
- There are a number of predicates present in TOY prolog that are not
- mentioned in C & M. I have not tried to determine what any of them do
- yet. ST specific predicates are provided to set and read the time and
- date, interact with the terminal, and execute VDI functions. While I
- have not tried to use them they seem fairly simple. Check the 'tictactoe'
- demo and the Abacus books.
-
- I would encourage anyone else who is using TOY Prolog to download this
- file, fix my mistakes, and add whatever information you have. Perhaps
- we can create our own documentation!
-
- Michael A. Long (MALONG)
- 8/28/87
-
- əəəəəəəəəəəəəəəəəəəəəəəəəəəə